package com.hyt.it.ogt.ks.mq;

import javax.annotation.Resource;

import org.springframework.amqp.AmqpException;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.core.MessagePostProcessor;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.stereotype.Component;

import com.alibaba.fastjson.JSON;
import com.hyt.it.ogt.ks.config.ConfigManager;
import com.hyt.it.ogt.ks.mq.model.FaceValidResultPhotoDownloadDTO;

import lombok.extern.slf4j.Slf4j;

/**
 * 人脸核身下载结果照片
 *
 * @author liuhh
 */
@Component
@Slf4j
public class FaceValidResultPhotoDownloadMqProducer {
    @Resource
    private ConfigManager configManager;
    @Resource
    private RabbitTemplate rabbitTemplate;

    public void sendMessage(FaceValidResultPhotoDownloadDTO obj) {
        //给延迟队列发送消息
        rabbitTemplate.convertAndSend(configManager.getDirect(),
                configManager.getDownloadFaceValidPhotoRoute(), JSON.toJSONString(obj),
                new MessagePostProcessor() {
                    @Override
                    public Message postProcessMessage(Message message) throws AmqpException {
                        return message;
                    }
                });
        log.info("send json:{}", obj.toString());
    }

}

